	$('#login-form').submit(function(event) {
		event.preventDefault();
		var $form = $(this);
		username = $form.find('input[name="username"]').val();
		password = $form.find('input[name="password"]').val(); 
		url = $form.attr('action');
		$.post(url, {username : username,password : password}, 
			function(data) {
				resultsLogin(data);
		});
	});
	
	function resultsLogin(data) {
		var arrayResponse = data.split(':'); 
		if(arrayResponse[0]== 'ERROR'){
			$('#error-message').empty().html(arrayResponse[1]);
		}
		else {
			var location = ""+window.location+"";
			location = location.replace("login","index");
			window.location.href = location;
		}
	}